<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组件：基本示例:全局注册</title>
</head>
<body>

    <div id="components-demo">
        <component-button></component-button>
        <component-button></component-button>
        <component-button></component-button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script type="text/javascript">
        // 全局注册
        // 注意：data 必须是一个函数
        Vue.component('component-button',{
            data:function(){
                return {count:0}
            },
            template:'<button v-on:click="count++">You clicked me {{count}} times</button>'
        });

        new Vue({el:"#components-demo"});
    </script>
</body>
</html>